<template>
	<view class="page">
		<view>
					<u-navbar  :autoBack="true" bgColor="#252928" safeAreaInsetTop placeholder="true">
						<view style="display: flex;" class="u-nav-slot" slot="left">
							<u-icon color="#ffffff" name="arrow-left" size="19"></u-icon>
							<view style="font-size: 36rpx;margin-left: 20rpx;">设置操作密码</view>
							
						</view>
					</u-navbar>
				</view>
		<view class="setpass">
			<view class="" style="font-size: 48rpx;">
				{{title}}
				
			</view>
			<template v-if="alter">
				<text style="color: #464a48;margin-right: 20rpx;">忘记密码?使用  </text> <text>实人认证</text>
			</template>
			<view class="inp" >
				<code-input disabledKeyboard="true" dot :focus="true" @finish="finish"  space=25 mode="box" v-model="value" ></code-input>
			</view>
		</view>
		
			<u-keyboard   mode="number" :dotDisabled="true" :show="show" :tooltip="false" @backspace="backspace" @close="close" :overlay="false" @change="change"></u-keyboard>
		
		
	</view>
</template>

<script>
	import codeInput from '../../../components/codeInput/code-input.vue' 
	
	export default {
		data() {
			return {
				title:"输入新操作密码",
				value:'',
				show:1,
				alter:0,
				i:0
			}
		},
		components:{
			codeInput
		},
		onLoad(e) {
			if(e.type==2){
				this.alter=1
				this.title="输入当前操作密码"
			}
			console.log(e)
		},
		mounted() {
		
		     setInterval(function(){  
		            uni.hideKeyboard();//隐藏软键盘  
		
		        },10);  
		},
		methods: {
			
			change(e){
				console.log(e)
				
				this.value = this.value + e
				
				console.log(this.value.length)
				if(this.value.length==6){
					this.finish(this.value)
					
				}
				
			},
			finish(e) {
				
				if(this.alter==1){
					this.value=''
					this.title="再次输入操作密码"
					
					this.i++
					console.log("i===" + this.i)
					if(this.i==2){
						uni.navigateTo({
							url:'../password/password?show=true'
						})
					}
				}else{
					uni.navigateTo({
					url:'../password/password?show=true'
				})}
				
				
							console.log('输入结束，当前值为：' + e);
						},
			close(){
				this.value = ''
			},
			backspace(){
				
				let s = this.value.toString()
				
				this.value =  s.substring(0,s.length-1)
				
				console.log(this.value)
			}
		}
	}
</script>

<style scoped>
	>>>.u-keyboard{
		background-color: #464a48!important;
	}
	>>>.u-keyboard__button-wrapper__button{
		background-color: #252726!important;
	}
	>>>.u-keyboard__button-wrapper__button__text{
		color: #FFFFFF!important;
	}
	>>>.u-icon__icon{
		color: #FFFFFF!important;	
	}
	>>>.u-keyboard__button-wrapper{
		box-shadow:none!important;
	}
	
	.setpass{
		
		width: 85%;
		margin: 200rpx 	auto 0rpx ;
	}
.inp{
	
	margin-top: 100rpx;
}

</style>
